import java.sql.*;

public class Test {

    static final String query="SELECT * FROM login WHERE NAME=?";

    static Connection connection=null;
    static PreparedStatement statement=null;
    static ResultSet set=null;

    public static void connection(String name) {

        try {
            Class.forName("com.mysql.jdbc.Driver");
        }catch(ClassNotFoundException e){
            System.out.println("发生了ClassNotFoundException错误");
        }
        try{
            Connection connection= DriverManager.getConnection("jdbc:mysql://localhost:3306/servlet","root","root");
            PreparedStatement statement=connection.prepareStatement(query);
            statement.setString(1,"黄彪5");
            set=statement.executeQuery();
            while(set.next()){
                System.out.println(set.getString(1)+"\n"+set.getString(2)+"\n"+set.getString(3));
            }
        }catch(SQLException e){
            e.printStackTrace();
            //System.out.println("发生了SQLException错误");
        }
    }
    public static void main(String[] args) {

        connection("黄彪5");


    }


}
